#include "HighScore.h"
#include <iostream>

HighScore::HighScore(void)
{
}


HighScore::~HighScore(void)
{
}


void HighScore::readFromFile()
{
	ifstream in;
	char c;

	in.open( "saveFile.txt" );

	while( !in.eof() )
	{
		HighScoreData temp;
		HighScoreData empty;


		in >> temp;
		if( temp != empty )
			scoreBoard.push_back(temp);
	}

	in.close();
}

void HighScore::writeToFile()
{
	ofstream out;

	out.open("saveFile.txt");

	for( int i = 0; i < scoreBoard.size(); i++ )
	{
		out << scoreBoard[i];
	}

	out.close();
}

void HighScore::printHighScore()
{
	sortScoreBoard();
	for( int i = 0; i < scoreBoard.size(); i++ )
	{
		std::cout << scoreBoard[i] << endl;
	}
}

void HighScore::addHighScoreData( HighScoreData &HSD )
{
	scoreBoard.push_back(HSD);
}

void HighScore::sortScoreBoard()
{
	sort( scoreBoard.begin(), scoreBoard.end() );
}